package ac.manchester.cs.afzal.tcm_processing.main;

import ac.manchester.cs.afzal.tcm_processing.terms_sentence_handler.Term_Head_Extractor;
import java.io.*;
import java.util.Vector;

import ac.manchester.cs.afzal.tcm_processing.nlp.*;
import ac.manchester.cs.afzal.tcm_processing.terms_sentence_handler.*;
import ac.manchester.cs.afzal.tcm_processing.term_similarities.*;
import ac.manchester.cs.afzal.tcm_processing.miscellaneous.*;

public class Main
{

    public static void main(String[] args)
    {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

        String input;
        try
        {
            System.out.println(
                    "*****************************************************");
            System.out.print(
                    "Please Choose among following options:\n" +
                    " 1. Download PMC Documents" +
                    " 2. Parse Chinese Medicine Documents"+ 
                    " 3. Clists to lst files generator \n" +
                    " 3a. Terms Extractor from CLISTS \n" +
                    " 4. Named Entity Tagging and Sentence Splitting (using GATE) \n" +
                    " 5. Sentence Splitter for each Term Occurrence \n" +
                    " 5a. Sentence Splitter for Disease Name Occurrences from GAD \n" +
                    " 5b. Sentence Splitter for Disease Name Occurrences from OBM \n" +
                    " 9. Map Terms to their Occurrences \n" +
                    " 6. Parse Sentences to PENN and CollapsedDependency \n" +
                    " 7. Convert PENN to XML \n" +
                    " 8. Stemmer  \n" +
                    " 9a.Load Seed Terms into Term Table (Term basis seed terms) \n" +
                    " 10.Context Builder \n" +
                    " 10a.Context Builder for Diseases GAD \n" +
                    " 11a.Context Similarity Calculator for Diseases GAD \n" +
                    " 12a. Lexical Comparison with Diseases  \n" +
                    " 12b. Lexical Comparison with Environment Factors  \n" +
                    " 13.Combined Similarity Calculator \n" +
                    " 14.Extract Heads from Newly Identified Terms \n" +
                    " 15.Prepare newly identified terms for metamap \n" +

                    " Enter number to continue or 'e' to exit : ");
            input = in.readLine();
            input = input.trim();

            if(input.equals("1")) // used 18-07-13 - To be tested
            {
                Download_PMC_Documents doc_down = new Download_PMC_Documents();
                doc_down.download_EntrezXML();
                doc_down.read_search_result();
                doc_down.download_pmcids("..\\TCM_Resources\\Data\\Corpus\\PMCIDs.xml");
            }

            if (input.equals("2"))
            {
                Parse_Chinese_Medicine_XML parse_cm = new Parse_Chinese_Medicine_XML();
                parse_cm.convert_pmc_xml_to_text();
            }
            if(input.equals("3")) // used 7-02-12
            {
                Occurrences_Generator_Impl lst_generator = new Occurrences_Generator_Impl();
                lst_generator.lst_files_generator();
            }
            else if(input.equals("3a")) // used 7-02-12
            {
                Terms_Generator_Impl terms_generator = new Terms_Generator_Impl();
                terms_generator.terms_extractor();
            }

            else if(input.equals("4")) // used 7-02-12
            {
                Term_Lookup_Impl term_lookup = new Term_Lookup_Impl();
                term_lookup.term_lookup_and_sentence_boundry_mark(true);
            }
            else if(input.equals("5")) // used 7-02-12
            {
                Sentence_Splitter_Impl sentence_splitter = new Sentence_Splitter_Impl();
                sentence_splitter.countering_lookup();
            }
            else if(input.equals("5a")) // used 7-02-12
            {
                Sentence_Splitter_Impl sentence_splitter = new Sentence_Splitter_Impl();
                sentence_splitter.countering_lookup_for_diease_gad();
            }

            else if(input.equals("5aa")) // used 7-02-12
            {
                Sentence_Splitter_Impl sentence_splitter = new Sentence_Splitter_Impl();
                sentence_splitter.countering_lookup_for_env_fac_gad();
            }

            else if(input.equals("5b")) // used 23-07-12
            {
                Sentence_Splitter_OBM sentence_splitter = new Sentence_Splitter_OBM();
                sentence_splitter.countering_lookup_for_obm_diseases();
            }

            else if(input.equals("9"))
            {
                Term_Mapping_Impl term_mapping = new Term_Mapping_Impl();
                term_mapping.terms_mapping(""); // other argument option is "unified_terms"
            }

            else if(input.equals("6"))
            {
                Parser_Impl parse_sentences = new Parser_Impl();
                parse_sentences.txt_to_penn_dep();
            }

            else if(input.equals("7"))
            {
                XML_Tree_Generator tree_conversion = new XML_Tree_Generator();
                tree_conversion.convert_penn_to_xml();
            }
            else if(input.equals("8"))
            {
                Stemming_Impl stemmer = new Stemming_Impl();
                stemmer.populate_stems_table();
            }
            else if(input.equals("9a"))
            {
                Term_Mapping_Impl term_mapping = new Term_Mapping_Impl();
                term_mapping.loadSeedTerms();
            }
            else if(input.equals("10"))
            {
                Context_Builder_Impl context_builder = new Context_Builder_Impl();
                context_builder.building_contexts();

            }
            else if(input.equals("10a"))
            {
                Context_Builder_Diseases_GAD context_builder_diseases_gad = new Context_Builder_Diseases_GAD();
                context_builder_diseases_gad.building_contexts_diseases_gad();
            }
            else if(input.equals("11a"))
            {
                Comparison_Contextual_Diseases_GAD consim = new Comparison_Contextual_Diseases_GAD();
                consim.contextual_similarity();
            }

            else if(input.equals("12a"))
            {
                Comparison_Lexical comparison_lexical = new Comparison_Lexical();
            }
            else if(input.equals("13"))
            {
                Combined_Similarity_Impl combined_similarity = new Combined_Similarity_Impl();
            }
            else if(input.equals("14"))
            {
                Term_Head_Extractor t_h = new Term_Head_Extractor();
                t_h.extract_heads();
            }
            else if(input.equals("15"))
            {
                Term_Head_Extractor t_h = new Term_Head_Extractor();
                t_h.prepare_new_terms_for_metamap();
            }

            else if(input.equals("e"))
            {
                System.exit(1);
            }
        }
        catch (Exception ex)
        {
            System.out.println(
                    "Value of Exception in reading input is : " + ex.getMessage());
        }
    }
}
